

function batchDel() {
    var arr = $("#medicperTable").bootstrapTable("getSelections");
    if(arr.length==0){
        swal({
            title:"提示",
            text:"请至少选择一项删除!"
        })
        return;
    }
    swal({
        title:"确认提示",
        text:"确认删除该信息？",
        type:"warning",
        showCancelButton:true,
        closeOnConfirm:false,
        confirmButtonText:"删除",
        confirmButtonColor:"#ec6c62"
    }).then(function () {
        var param = $(arr).map(function () {
            return "woJubnum="+this.woJubnum;
        }).get().join("&");
        $.post(ctx+"/doc/del",param,function (msg) {
            toastr.info(msg);
            $("#medicperTable").bootstrapTable("refresh");
        })
    })
}

function del(woJubnum) {
    swal({
        title:"确认提示",
        text:"确认删除该信息？",
        type:"warning",
        showCancelButton:true,
        closeOnConfirm:false,
        confirmButtonText:"删除",
        confirmButtonColor:"#ec6c62"
    }).then(function () {

        $.post(ctx+"/doc/del","woJubnum="+woJubnum,function (msg) {
            toastr.info(msg);
            $("#medicperTable").bootstrapTable("refresh");
        })
    })
}

//单机操作方法
window.optEvents = {
    "click .display":function (e,value,row) {
        var woJubnum = row.worker.woJubnum;//获取员工编号
        var perId = row.perId
        location.href=ctx+"/doc/display?woJubnum="+woJubnum+"&perId="+perId;
    },
    "click .edit":function (e,value,row) {
        var woJubnum = row.worker.woJubnum;//获取员工编号
        location.href=ctx+"/doc/edit?woJubnum="+woJubnum;
    },
    "click .del":function (e,value,row) {
        var woJubnum = row.worker.woJubnum;//获取员工编号
        del(woJubnum);
    }
}
//添加方法
function add() {
    location.href=ctx+"/doc/add";
}

//获取操作的方法
function optEvent() {
    var opt = '<button class="layui-btn layui-btn-normal layui-btn-mini edit">编辑</button>' +
        '<button type="button"  class="layui-btn layui-btn-danger layui-btn-mini del">删除</button>' +
        '<button type="button"  class="layui-btn layui-btn-info layui-btn-mini display">详情</button>';
    return opt;
}

//搜索日期插件
$(function () {
   laydate.render({
       elem:'[name=startDate]'
   })
    laydate.render({
        elem:'[name=endDate]'
    })
});




$(function () {
    initRole();
});
function initRole() {
   var deId = $("#woJ").val();
   if(deId!=1){

       /*$.post(ctx+"/doc/searchRole","deId="+deId,function (arr) {
           $.each(arr,function () {
               var $opt = $("<option/>");
               $opt.val(this.roleId);
               $opt.html(this.roleName);
               $opt.appendTo("#roleId")
           });
       });*/
       $.ajax({
           url:ctx+"/doc/searchRole",
           type:"post",
           data:"deId="+deId,
           dataType:"json",
           success:function (arr) {
               $.each(arr,function () {
                   var $opt = $("<option/>");
                   $opt.val(this.roleId);
                   $opt.html(this.roleName);
                   $opt.appendTo("#roleId")
               });
           }
       })
   }
   if(deId==1){
       $("#dong").html("所属科室:");
       $("#roleId").attr("name","divCode");//改变成为科室名称
       $("#roleId").children(":eq(0)").val("")//让他的value变成空
       $.ajax({
           url:ctx+"/doc/searchDivision",
           type:"post",
           dataType:"json",
           success:function (arr) {
               $.each(arr,function () {
                   var $opt = $("<option/>");
                   $opt.val(this.divCode);
                   $opt.html(this.divName);
                   $opt.appendTo("#roleId");
               });
           }
       })
   }
}
//搜索条件查询方法
function searchMedicper() {
    var param={};
    param.woName=$("#condition [name=woName]").val();//医护人员姓名
    var startDate = $("#condition [name=startDate]").val();//生日开始
    if(startDate!=''){
        param.startDate=startDate;
    }
    var endDate = $("#condition [name=endDate]").val();//生日结束
    if(endDate!=''){
        param.endDate=endDate;
    }
    param.divCode=$("#condition [name=divCode]").val();//科室编号
    param.woRoleId = $("#condition [name=woRoleId]").val();//角色Id
    param.phone=$("#condition [name=phone]").val();//联系电话
    console.log(param)
    $("#medicperTable").bootstrapTable("refresh",{query:param})
}
function showValue(obj){
    searchMedicper();
}

